//
//  NewDeviceCell.m
//  YSSmartHome
//
//  Created by yanghao on 2016/12/30.
//  Copyright © 2016年 yahaong. All rights reserved.
//

#import "NewDeviceCell.h"
#import "YHMarcros.h"
@interface NewDeviceCell ()
@property (nonatomic, strong) UIButton* m_btnSelect;
@property (nonatomic, strong) UILabel* m_lblTitle;

@end
@implementation NewDeviceCell

- (void)awakeFromNib {
    [super awakeFromNib];
    [self setupUI];
}

- (instancetype) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setupUI];
    }
    return self;
}

- (void)setupUI
{
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    [self.contentView addSubview:self.m_btnSelect];
    [self.contentView addSubview:self.m_lblTitle];
    [self.m_btnSelect mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.leading.equalTo(self.contentView).offset(kIphoneSize_Widith(10));
    }];
    [self.contentView addSubview:self.m_lblTitle];
    [self.m_lblTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.leading.equalTo(self.m_btnSelect.trailing).offset(kIphoneSize_Widith(10));
    }];
}

- (void)setDevmode:(NotAddedDev *)devmode
{
    _devmode = devmode;
    self.m_lblTitle.text = devmode.title;
    self.m_btnSelect.selected = devmode.isSelect;
}
#pragma mark - lazy loading

- (UIButton *)m_btnSelect
{
    if (!_m_btnSelect) {
        _m_btnSelect = [UIButton buttonWithType:UIButtonTypeCustom];
        [_m_btnSelect setImage:[UIImage imageNamed:@"me_newdevice_normal"] forState:UIControlStateNormal];
        [_m_btnSelect setImage:[UIImage imageNamed:@"me_newdevice_selected"] forState:UIControlStateSelected];
        _m_btnSelect.userInteractionEnabled = false;
    }
    return _m_btnSelect;
}
- (UILabel *) m_lblTitle
{
    if (!_m_lblTitle)
    {
        _m_lblTitle = [[UILabel alloc ]init];
        _m_lblTitle.font = [UIFont systemFontOfSize:15];
    }
    return _m_lblTitle;
}
@end
